<?php
namespace Plu\Library\Models\Platform\Album;

use Phalcon\Mvc\Model,
    Phalcon\Db\Column;

class Album extends Model {
    public $Id;
    public $RoomId;
    public $AlbumName;
    public $AlbumAbbrDefault;
    public $AlbumAbbr;
    public $GameId;
    public $AlbumDesc;
    public $UpdateDatePlan;
    public $AlbumPic;
    public $IsValid;
    public $MediaCount;
    public $ScheduleId;
    public $SchedulePic;
    public $ScheduleTitle;
    public $WriteTime;

    public function initialize() {
        $this->setReadConnectionService('db.LongzhuMediaReadOnly');
        //$this->hasMany('Id', 'AlbumOfMedia', 'AlbumId');
    }

    public function getSource() {
        return "Album";
    }

    /**
     * 根据roomid 获取有效的专辑
     */
    public static function getItemsByRoomId($roomid) {
        $items = self::find(array(
            "RoomId = :roomid: AND IsValid = 1",
            "bind" => array(
                "roomid" => $roomid
            ),
            "bindTypes"  => array(
                "roomid" => Column::BIND_PARAM_INT
            ),
        ));

        if (count($items)) {
            return $items->toArray();
        } else {
            return false;
        }
    }
}
?>
